# encoding=utf-8
import pandas as pd

from application.logging import logger
from application.utils.MySQLUtils import MySQLUtils


def func_get_area_code(station_id):
    """
    查询地区编码
    :param station_id: 换热站编号
    :return: 地区编码
    """
    # 查询语句
    sql = f"SELECT area_id FROM basic_business_hot_station WHERE energy_org_id = '{station_id}'"
    logger.info(f"查询语句: {sql}")
    # 获取连接
    con = MySQLUtils.get_mysql_connection()
    # 查询数据
    df = pd.read_sql_query(sql=sql, con=con)
    logger.info(f"查询结果: \n {df}")
    # 处理数据
    area_id = list(df["area_id"])[0]
    logger.info(f"地区编码: {area_id}")
    # 返回数据
    return area_id
    pass


if __name__ == '__main__':
    print(func_get_area_code(station_id="1353374478217908224"))
    pass
